﻿using GraphProcessor;
using IQIGame.Onigao.Logic;
using UnityEngine;

namespace IQIGame.Onigao.GamePlay.Editors
{
    [System.Serializable, NodeMenuItem(LevelEditorConst.Execution + "/" + LevelEditorConst.RelationalCalcLevelParams, typeof(LevelServiceGraph))]
    public class LevelServiceExecutionNode_RelationalCalcLevelParams : LevelServiceExecutionNode
    {
        protected override ServiceExecutionType mServiceType => ServiceExecutionType.RelationalCalcLevelParams;

        public override string name => LevelEditorConst.RelationalCalcLevelParams;
        [LevelServiceEditorCustomProperty(ServiceExecutionType.RelationalCalcLevelParams, "修改模式"), Tooltip("1:设置 2:增加 3.减少")]
        public int type;
        [LevelServiceEditorCustomProperty(ServiceExecutionType.RelationalCalcLevelParams, "LevelParam表ID(可写参数)")]
        public int writeParamId;
        [LevelServiceEditorCustomProperty(ServiceExecutionType.RelationalCalcLevelParams, "LevelParam表ID(可读参数)")]
        public int readParamId;

        protected override LevelServiceCustomConfig CreateConfig()
        {
            var rConfig = new LevelServiceExecutionCustom_RelationalCalcLevelParams()
            {
                type = this.type,
                writeParamId = this.writeParamId,
                readParamId = this.readParamId
            };
            return rConfig;
        }
        
        protected override void OnSync(EditorLevelServiceExecutionConfig newConfig, LevelServiceExecutionNode tempNode)
        {
            if (tempNode is LevelServiceExecutionNode_RelationalCalcLevelParams rNode)
            {
                this.type = rNode.type;
                this.writeParamId = rNode.writeParamId;
                this.readParamId = rNode.readParamId;
            }
        }
    }
}